<?php

namespace App\Http\Controllers\Api;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * $msg   返回提示消息
     * $data  返回数据
     */
    public function success($data = [],$msg='成功')
    {
        return response()->json([
            'status' => true,
            'code' => 200,
            'message' => $msg,
            'data' => $data,
        ]);
    }

    /**
     * $msg   返回提示消息
     * $data  返回数据
     */
    public function fail($data = [],$msg='错误',$code=500)
    {
        return response()->json([
            'status' => false,
            'code' => $code,
            'message' => $msg,
            'data' => $data,
        ]);
    }

}
